<template>
	<view class="content">
		<button type="default" @click="handleclick">授权</button>
		<view class="" v-for="(item, index) in Location" :key="index">
			{{item}}
		</view>
	</view>
</template>

<script>
	import locationWxApi from '@/common/location/location_wx';
	import locationAppApi from '@/common/location/location_app';
	export default {
		data() {
			return {
				Location: []
			}
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			this.getAuthorizeClass();
			// #endif
			
			// #ifdef APP-PLUS
			this.getlocationAppClass();
			// #endif
		},
		methods: {
			
			handleclick(){
				// #ifdef MP-WEIXIN
				this.getloactionClass();
				// #endif
				
				// #ifdef APP-PLUS
				this.getlocationAppClass();
				// #endif
			},
			
			// #ifdef MP-WEIXIN
			async getAuthorizeClass(){
				try{
					const {latitude, longitude} = await locationWxApi.authorizeAction();
					this.Location.push(latitude+';'+longitude);
				}catch(e){
					console.log(e);
				}
			},
			
			async getloactionClass(){
				try{
					const {latitude, longitude} = await locationWxApi.settingAction();
					this.Location.push(latitude+';'+longitude);
				}catch(e){
					console.log(e);
				}
			},
			// #endif
			
			// #ifdef APP-PLUS
			async getlocationAppClass(){
				try{
					const {latitude, longitude} = await locationAppApi.authorizeAction();
					this.Location.push(latitude+';'+longitude);
				}catch(e){
					console.log(e);
				}
			}
			// #endif
			
		}
	}
</script>

<style>

</style>
